package com.shensi.api.pay.client;


import com.shensi.api.pay.pojo.CouponVerification;
import com.shensi.api.pay.pojo.CouponVerificationUser;
import com.shensi.api.pay.pojo.DrawCoupon;
import com.shensi.api.pay.pojo.dto.CancelCouponDto;
import com.shensi.api.pay.pojo.vo.CouponInfoVO;
import com.shensi.common.core.constant.CloudConstant;
import com.shensi.api.pay.param.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <Title> CouponController </Title>
 * <Description> 无力吐槽的优惠券设计，无力吐槽的表结构设计</Description>
 *
 * @Date 2021年12月3日
 */


@Api(tags = "优惠券")
@FeignClient(name = CloudConstant.PAY_SERVER, path = "appUser/order")
public interface CouponClient {


    /*
     * 领取方式查询优惠券
     * @return
     */
    @ApiOperation(value = "领取方式查询优惠券", httpMethod = "GET")
    @GetMapping("/selectCouponListByCouponIssueId")
    public String selectCouponListByCouponIssueId(@RequestParam("couponIssueId") String couponIssueId, @RequestParam("ordNo")String ordNo, @RequestParam("mobilePhone")String mobilePhone);


    /**
     * 优惠券业务逻辑说明：（牛掰的优惠券设计与表结构！！！后来者如有能力重写或重设计此部分业务逻辑吧。。。其他地方也会有臃肿的代码，如有能力能改业务设计就改吧。。）
     * 用户领取优惠券时 会携带随机数 randomFlag；根据传来随机数是否一样来判断是否是同一次进入领取优惠券页面；
     * couDrawStatus：标识用户领取优惠券状态，用于前端展示;(用户一次进来分多次领取)
     * 用户领取优惠券
     *
     * @param drawCoupon
     * @return
     */
    @Transactional
    @ApiOperation(value = "用户领取优惠券", httpMethod = "POST")
    @PostMapping("/drawCoupons")
    public String drawCoupons(@RequestBody DrawCoupon drawCoupon);

    /***
     * 查询用户的优惠券
     * @param mobilePhone
     * @param mobilePhone
     * @param couponIsUsed
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/selectUserCoupons", method = RequestMethod.GET)
    @ApiOperation(value = "获取客户所拥有的优惠券")
    public String selectUserCoupons(@ApiParam(value = "油企ID", required = true) @RequestParam("enterpriseId") Integer enterpriseId,
                                    @ApiParam(value = "用户手机号", required = true) @RequestParam("mobilePhone") String mobilePhone,
                                    @ApiParam(value = "优惠券状态couponIsUsed", required = true) @RequestParam("couponIsUsed") String couponIsUsed,
                                    @RequestParam("pageNum") int pageNum, @RequestParam("pageSize") int pageSize);

    /***
     * 核销人员登录
     * @param cvu
     * @return
     */
    @PostMapping("/verificationUserLogin")
    @ApiOperation(value = "核销人员登录")
    public String verificationUserLogin(@RequestBody CouponVerificationUser cvu);

    /**
     * 查询核销的优惠券
     *
     * @param cver
     * @return
     */
    @PostMapping("/selectVerCouponInfo")
    @ApiOperation(value = "查询核销的优惠券")
    public String selectVerCouponInfo(@RequestBody CouponVerification cver);

    /***
     * 优惠券核销
     * @param cv
     * @return
     */
    @PostMapping("/writeOffCoupon")
    @Transactional
    @ApiOperation(value = "优惠券核销")
    public String writeOffCoupon(@RequestBody CouponVerification cv);


    /**
     * 查询用户已核销的优惠券列表
     *
     * @param userName
     * @return
     */
    @GetMapping("/selectVerUserCouponList")
    public String selectVerUserCouponList(@RequestParam("userName") String userName, @RequestParam("pageNum") int pageNum, @RequestParam("pageSize") int pageSize);


    /**
     * 测试
     *
     * @param mobilePhone
     * @param stationId
     * @param amt
     * @return
     */
    @GetMapping("/initiativeCoupon")
    public String initiativeCoupon(@RequestParam("mobilePhone")String mobilePhone, @RequestParam("stationId")Integer stationId,@RequestParam("amt") String amt);


    //    提供给支付后发券  这里只有wx zfb dzk支付
    @PostMapping("/drawCouponsCopy")
    public String drawCouponsCopy(@RequestBody DrawCoupon drawCoupon);


    @GetMapping("/getRegisterCoupon")
    @ApiOperation(value = "获取注册发券的优惠券", notes = "获取注册发券的优惠券")
    @ResponseBody
    public String getRegisterCoupon(@ApiParam(value = "油企ID", required = true) @RequestParam("enterpriseId") Integer enterpriseId,
                                    @ApiParam(value = "用户手机号", required = true) @RequestParam("mobilePhone") String mobilePhone);


    @RequestMapping(value = "/cancelCoupon", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "优惠券扫码核销", httpMethod = "POST", notes = "优惠券扫码核销")
    public ResultData<?> cancelCoupon(@Valid @RequestBody CancelCouponDto cancelCouponDto);

    @GetMapping("/getIfCancelCouponSuccess")
    @ResponseBody
    @ApiOperation(value = "获取扫码核销的优惠券信息", httpMethod = "GET", notes = "获取扫码核销的优惠券信息")
    public ResultData<CouponInfoVO> getIfCancelCouponSuccess(@ApiParam(value = "优惠券码", required = true) String couponNo);
}
